package com.atguigu.yygh.msm.listener;

import com.atguigu.yygh.rabbit.consts.MqConst;
import com.atguigu.yygh.vo.msm.MsmVo;
import org.springframework.amqp.rabbit.annotation.Exchange;
import org.springframework.amqp.rabbit.annotation.Queue;
import org.springframework.amqp.rabbit.annotation.QueueBinding;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.stereotype.Component;

@Component
public class MsmListener {

    @RabbitListener(
            bindings = {
                    @QueueBinding(
                            value = @Queue(name = MqConst.MSM_QUEUE,declare = "true",durable = "true"),
                            exchange = @Exchange(name = MqConst.MSM_EXCHANGE,declare = "true",durable = "true"),
                            key = MqConst.MSM_KEY
                    )
            }
    )
    public void listenerMsmQueue(MsmVo msmVo){
        System.out.println("短信服务监听到消息");

        String message = msmVo.getMessage();  //短信内容
        String phone = msmVo.getPhone();   //手机号
        System.out.println("手机号:"+phone);
        System.out.println("短信内容"+message);
    }
}
